% just scaling spectra
% latest date 07.08.2002

function[SPM] = ScaleSPM(SPM,ProcDef),

MaxVal=ProcDef.MaxVal;
MinVal=ProcDef.MinVal;
ScaleVal=ProcDef.ScaleVal;


A = size(SPM);

for j = 1:A(2),
   for i = 1:A(1),
      if min(SPM(i,j,:,:)) < MinVal,
         SPM(i,j,:,:)=SPM(i,j,:,:)*ScaleVal;
      elseif max(SPM(i,j,:,:)) > MaxVal,
         SPM(i,j,:,:) = SPM(i,j,:,:)/ScaleVal;
      end;
        
   end;
end;

